<template>
    <div class="app-container">
        <div class="head">
            <img src="@/assets/img/Layout/position.png" />
            <p class="see-block">账号绑定列表</p>
        </div>
        <div class="view-container">
            <el-form :model="queryParams" ref="queryForm" :inline="true">
                <el-form-item label="账号查询" prop="userName">
                    <el-input
                        v-model="queryParams.userName"
                        placeholder="账号查询检索"
                        clearable
                        size="small"
                        style="width: 230px;"
                        @keyup.enter.native="handleQuery"
                    />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" class="list-search btn-success" color="#5ED4D4">搜索</el-button>
                    <el-button icon="el-icon-refresh" size="mini" @click="resetQuery" class="list-search">重置</el-button>
                </el-form-item>
            </el-form>
            <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                    <el-button
                        class="btn-success"
                        type="primary"
                        icon="el-icon-plus"
                        size="mini"
                        @click="handleAdd()"
                        v-hasPermi="['system:dealerBinding:insert']"
                    >新建</el-button>
                </el-col>
            </el-row>
            <el-table v-loading="loading" :data="list" border>
                <el-table-column label="序号" type="index" align="center" width="50">
                    <template slot-scope="scope">
                        <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="租户账号"  align="center" prop="userName" />
                <!-- <el-table-column label="密码" align="center" prop="password" /> -->
                <el-table-column label="地址" align="center" prop="address" />
                <el-table-column label="联系电话" align="center" prop="phone" />
                <el-table-column label="联系人" align="center" prop="contacts" />
                <el-table-column label="公司名称" align="center" prop="corporateName" />
                <el-table-column label="备注" align="center" prop="remark" />
                <el-table-column label="操作" align="center" fixed="right" width="170">
                    <template slot-scope="scope">
                        <!-- <el-button
                            size="mini"
                            type="text"
                            icon="el-icon-edit"
                            @click="handleUpdate(scope.row)"
                            v-hasPermi="['system:dealerBinding:update']"
                        >编辑</el-button> -->
                        <el-button
                            size="mini"
                            type="text"
                            icon="el-icon-document"
                            @click="handleDetail(scope.row)"
                            v-hasPermi="['system:dealerBinding:selectOne']"
                        >详情</el-button>
                        <el-button
                            size="mini"
                            type="text"
                            icon="el-icon-delete"
                            @click="handleDelete(scope.row)"
                            v-hasPermi="['system:dealerBinding:deleteById']"
                        >删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <pagination
                v-show="total > 0"
                :total="total"
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                @pagination="getList"
            />
        </div>
    </div>
</template>

<script>
import { list, del } from "@/api/system/dealerBinding/dealerBinding"
export default {
    name: "list",
    data() {
        return {
            loading: true,
            total: 0,
            list: [],
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                userName: undefined,
            }
        }
    },
    created() {
        this.getList()
    },
    methods: {
        // 获取列表
        getList() {
            this.loading = true
            list(this.addDateRange(this.queryParams)).then(res => {
                this.list = res.rows
                this.total = res.total
                this.loading = false
            })
        },
        // 搜索按钮
        handleQuery() {
            this.queryParams.pageNum = 1
            this.getList()
        },
        // 重置按钮
        resetQuery() {
            this.resetForm("queryForm")
            this.handleQuery()
        },
        // 新增
        handleAdd(){
            this.$router.push({ path:"/dealerBinding/add" })
        },
        // 编辑
        handleUpdate(row) {
            this.$router.push({ path:"/dealerBinding/edit", query:{id: row.id}})
        },
        // 详情
        handleDetail(row){
            this.$router.push({ path:"/dealerBinding/detail", query:{id: row.id}})
        },
        // 删除
        handleDelete(row){
            this.$modal.confirm('是否确认删除？').then(() => {
                del(row.id).then(() => {
                    this.getList()
                    this.$modal.msgSuccess("删除成功")
                })
            }).catch(() => {})
        }
    }
}
</script>